package com.example.test622.detail

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageView
import com.example.test622.R
import com.google.android.material.bottomsheet.BottomSheetDialogFragment


class DanmuBottomSheetDialogFragment : BottomSheetDialogFragment() {
	 lateinit var et:EditText
	 lateinit var send:ImageView
	override fun onCreate(savedInstanceState: Bundle?) {
		super.onCreate(savedInstanceState)
	}
	
	override fun onCreateView(
		inflater: LayoutInflater, container: ViewGroup?,
		savedInstanceState: Bundle?
	): View? {
		// Inflate the layout for this fragment
		val view =  inflater.inflate(R.layout.fragment_danmu_bottom_sheet_dialog, container, false)
		initView(view)
		return view
	}
	private fun initView(view: View?) {
		if (view != null) {
			et = view.findViewById(R.id.et_danmu)
		}
		if (view != null) {
			send = view.findViewById(R.id.iv_danmu_send)
		}
		send.setOnClickListener {
			if(listener!=null){
				listener.onclick()
			}
		}
	}
	fun close(){
		et.text.clear()
		dismiss()
	}
	fun setDanmuOnClickListener(listener:DanmuClickListener){
		this.listener = listener
	}
	private lateinit var listener:DanmuClickListener
	interface DanmuClickListener{
		fun onclick()
	}
}